import sys
from rclpy.node import Node
from sum_interfaces.srv import Sum


class SumServiceClient(Node):
    def __init__(self, name):
        super().__init__(name)
        self.client = self.create_client(Sum, "add_two_ints")
        while not self.client.wait_for_service(timeout_sec=1.0):
            self.get_logger().info("service not available, waiting again...")
        self.request = Sum.Request()

    def send_request(self):  # 创建一个发送服务请求的函数
        self.request.a = int(sys.argv[1])
        self.request.b = int(sys.argv[2])
        self.future = self.client.call_async(self.request)
